package xyz.xtt.equity.constants;

import static java.util.stream.Collectors.toList;

import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.stream.Stream;

import com.alibaba.cloud.commons.lang.StringUtils;
import com.google.common.collect.Lists;

/**
 * @ClassName：EquityTypeEnum
 * @Author: XGP
 * @Date: 2024/12/31/0031 17:47
 * @Desc: 权益类型枚举
 */
public enum EquityTypeEnum {
	EQUITY_TYPE_01(1, "元素NFT", "ELEMENT"), EQUITY_TYPE_02(2, "数字人专属套装", "SUIT"), EQUITY_TYPE_03(3, "数字会员权益", ""), EQUITY_TYPE_04(4, "供应链开发能力", ""),
	EQUITY_TYPE_05(5, "超级社群", "SUPER_GROUP"), EQUITY_TYPE_06(6, "靓号手机号", ""), EQUITY_TYPE_07(7, "通通创世会员勋章", "INSIGNE"), EQUITY_TYPE_08(8, "领导管理系列课程", "");

	/**
	 * 权益类型编号
	 **/
	int equityNum;
	/**
	 * 权益描述
	 **/
	String equityDesc;
	String thirdType;

	EquityTypeEnum(int equityNum, String equityDesc, String thirdType) {
		this.equityNum = equityNum;
		this.equityDesc = equityDesc;
		this.thirdType = thirdType;
	}

	public int equityNum() {
		return equityNum;
	}

	public String equityDesc() {
		return equityDesc;
	}

	public String thirdType() {
		return thirdType;
	}

	public static EquityTypeEnum queryConvert(Integer checkType) {
		return Arrays.asList(EquityTypeEnum.values()).stream().filter(x -> Objects.equals(x.equityNum(), checkType)).findFirst().orElse(null);
	}

	public static List<Integer> equityTypes() {
		return Arrays
				.asList(EQUITY_TYPE_01.equityNum(), EQUITY_TYPE_02.equityNum(), EQUITY_TYPE_03.equityNum(), EQUITY_TYPE_04.equityNum(), EQUITY_TYPE_05
						.equityNum(), EQUITY_TYPE_06.equityNum(), EQUITY_TYPE_07.equityNum(), EQUITY_TYPE_08.equityNum());
	}

	// EQUITY_TYPE_05.equityNum 暂时去除社群调用
	public static List<Integer> limitEquityTypes() {
		Stream.of(EquityTypeEnum.values()).filter(x -> StringUtils.isNotBlank(x.thirdType())).collect(toList());
		return Arrays.asList(EQUITY_TYPE_01.equityNum(), EQUITY_TYPE_02.equityNum(), EQUITY_TYPE_05.equityNum(), EQUITY_TYPE_07.equityNum());
	}

	public boolean checkThirdRequest() {
		List<String> typeList = Lists.newArrayList("ELEMENT", "SUIT", "SUPER_GROUP", "INSIGNE");
		return typeList.stream().anyMatch(x -> Objects.equals(thirdType(), x));
	}

	// EQUITY_TYPE_05.equityNum 暂时去除社群调用
	public static List<EquityTypeEnum> thirdRequestType() {
		return Stream.of(EquityTypeEnum.values()).filter(x -> StringUtils.isNotBlank(x.thirdType())).collect(toList());
	}

	public static EquityTypeEnum requestType(int equityType) {
		return Stream.of(EquityTypeEnum.values())
//				.filter(x -> StringUtils.isNotBlank(x.thirdType()))
				.filter(x -> Objects.equals(equityType, x.equityNum()))
				.findAny()
				.orElse(null);
	}

	public static List<Integer> saveEquityTypes() {
		return Arrays.asList(EQUITY_TYPE_03.equityNum(), EQUITY_TYPE_04.equityNum(), EQUITY_TYPE_06.equityNum(), EQUITY_TYPE_08.equityNum());
	}

}
